//
//  ExampleProvider.swift
//  ESTabBarControllerExample
//
//  Created by lihao on 2017/2/9.
//  Copyright © 2018年 Egg Swift. All rights reserved.
//

import UIKit
import ESTabBarController_swift

enum ExampleProvider {
    static func systemRemindStyle() -> UITabBarController {
        let tabBarController = UITabBarController()
        let v1 = FirstViewController()
        let v2 = FirstViewController()
        let v3 = FirstViewController()
        let v4 = FirstViewController()
        let v5 = FirstViewController()
        
        v1.tabBarItem = UITabBarItem.init(title: "Home", image: UIImage(named: "home"), selectedImage: UIImage(named: "home_1"))
        v2.tabBarItem = UITabBarItem.init(title: "Find", image: UIImage(named: "find"), selectedImage: UIImage(named: "find_1"))
        v3.tabBarItem = UITabBarItem.init(title: "Photo", image: UIImage(named: "photo"), selectedImage: UIImage(named: "photo_1"))
        v4.tabBarItem = UITabBarItem.init(title: "Favor", image: UIImage(named: "favor"), selectedImage: UIImage(named: "favor_1"))
        v5.tabBarItem = UITabBarItem.init(title: "Me", image: UIImage(named: "me"), selectedImage: UIImage(named: "me_1"))
        
//        v1.tabBarItem.badgeValue = "New"
//        v2.tabBarItem.badgeValue = "99+"
//        v3.tabBarItem.badgeValue = "1"
        if let tabBarItem = v3.tabBarItem as? ESTabBarItem {
            tabBarItem.badgeColor = UIColor.blue
        }
//        v4.tabBarItem.badgeValue = ""
//        v5.tabBarItem.badgeValue = nil
        
        tabBarController.viewControllers = [v1, v2, v3, v4, v5]
        
        return tabBarController
    }
    
    static func customIrregularityStyle(delegate: UITabBarControllerDelegate?) -> ExampleNavigationController {
        let tabBarController = ESTabBarController()
        tabBarController.delegate = delegate
        tabBarController.title = "Irregularity"
        tabBarController.tabBar.shadowImage = UIImage(named: "transparent")
        tabBarController.tabBar.backgroundImage = UIImage(named: "backTopView的副本")
//        tabBarController.tabBar.backgroundColor = UIColor("#060C33")
        tabBarController.shouldHijackHandler = {
            tabbarController, viewController, index in
            if index == 1 {
                return false
            }
            return false
        }
//        tabBarController.didHijackHandler = {
//            [weak tabBarController] tabbarController, viewController, index in
//
//            DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
//                let alertController = UIAlertController.init(title: nil, message: nil, preferredStyle: .actionSheet)
//                let takePhotoAction = UIAlertAction(title: "Take a photo", style: .default, handler: nil)
//                alertController.addAction(takePhotoAction)
//                let selectFromAlbumAction = UIAlertAction(title: "Select from album", style: .default, handler: nil)
//                alertController.addAction(selectFromAlbumAction)
//                let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
//                alertController.addAction(cancelAction)
//                tabBarController?.present(alertController, animated: true, completion: nil)
//            }
//        }
        
        let v1 = FirstViewController()
        let v2 = SecondViewController()
        let v3 = SecondViewController()
        let v4 = FirstViewController()
        let v5 = ThirdViewController()
        
        
        v1.tabBarItem = ESTabBarItem.init(ExampleIrregularityBasicContentView(), title: XALanguageManager.getString(key: "资产") , image: UIImage(named: "钱包 - 露出一张卡片的一角"), selectedImage: UIImage(named: "钱包 - 露出一张卡片的一角"))
        v2.tabBarItem = ESTabBarItem.init(ExampleIrregularityBasicContentView(), title: "Find", image: UIImage(named: "find"), selectedImage: UIImage(named: "find_1"))
        v3.tabBarItem = ESTabBarItem.init(ExampleIrregularityContentView(), title: nil, image: UIImage(named: "组 11lll")?.withRenderingMode(.alwaysOriginal), selectedImage: UIImage(named: "组 11lll")?.withRenderingMode(.alwaysOriginal))
        
        //?.withRenderingMode(.alwaysOriginal)
//        v3.tabBarItem.selectedImage = UIImage.init(named: "组 11lll")?.withRenderingMode(.alwaysOriginal)
        
//            [[UIImage, imageNamed,:[imageName stringByAppendingString:@"_Sel"]]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]

        v4.tabBarItem = ESTabBarItem.init(ExampleIrregularityBasicContentView(), title: "Favor", image: UIImage(named: "favor"), selectedImage: UIImage(named: "favor_1"))
        v5.tabBarItem = ESTabBarItem.init(ExampleIrregularityBasicContentView(), title: XALanguageManager.getString(key: "设置"), image: UIImage(named: "设置"), selectedImage: UIImage(named: "设置"))
        
        
        tabBarController.viewControllers = [v1,  v3,  v5]
        
        let navigationController = ExampleNavigationController.init(rootViewController: tabBarController)
        tabBarController.title = ""
        //navigationController.isNavigationBarHidden = true
        return navigationController
    }
    

}
